package com.sky.mapper;

import com.sky.entity.DishEntity;
import com.sky.entity.SetmealDishEntity;
import com.sky.vo.SetmealDishWithUserVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    Integer countDishId(@Param("ids") List<Long> ids);

    @Select("select * from setmeal_dish where dish_id = #{id}")
    SetmealDishEntity getByDishId(Long id);

    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDishEntity> getBySetmealId(Integer setmealId);

    @Select("select dish.price,dish.description,dish.image,dish.name from dish left join setmeal_dish on dish.id = setmeal_dish.dish_id where setmeal_dish.setmeal_id = #{setmealId}")
    List<SetmealDishWithUserVO> getBySetmealIdWithUser(@Param("setmealId") Integer setmealId);


    void saveBatch(@Param("list") List<SetmealDishEntity> entities);

    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void delBySetmealId(@Param("setmealId") Long setmealId);

    @Select("select * from dish left join setmeal_dish on dish.id = setmeal_dish.dish_id and dish.status = 0 where setmeal_dish.setmeal_id = #{setmealId}")
    List<DishEntity> getDishBySetmealIdWithDisabled(@Param("setmealId") Long setmealId);

    void deleteBatchBySetmealId(@Param("ids") List<Long> ids);
}
